#include <stdio.h>

static long num_rects = 1000000;

int main(int argc, char* argv[])
{
   double mid, height, width, sum=0.0;
   int i;
   double area;

   width = 1./(double)num_rects;

   for (i=0; i<num_rects; i++) {
       mid = (i + 0.5) * width;
       height = 4.0/(1.+mid*mid);
       sum += height;
   }

   area = width * sum;

   printf("The value of PI is %f\n", area);
   return 0;
}
